<?php
/**
 * File: Apply.class.php
 * Author: camy <375766145@qq.com>
 * Time: 2018/3/24 14:55
 */

namespace Common\Extend\DingTalk\Message\Check;

use Common\Extend\DingTalk\Message\BaseMessage;

class Apply extends BaseMessage
{
    public function send($param)
    {
        //标题
        $this->title = '审核提醒';
        $checkWork = M('checkWork')->find($param['id']);
        //设置跳转地址-审核列表页面
        $this->setUrl('check/index', ['type' => 2, 'status' => 0, 'check_type' => $checkWork['type']]);
        //发送人
        $people = $this->getUserId($param['user_id']);
        //发送内容
        switch ($checkWork['type']) {
            case 10:
                $checkName = '预计积分申请';
                break;
            case 11:
                $checkName = '实际积分申请';
                break;
            case 12:
                $checkName = '项目附件';
                break;
            case 20:
                $checkName = '合同创建';
                break;
            case 21:
                $checkName = '合同支付';
                break;
            case 30:
                $checkName = '入库单创建';
                break;
            case 40:
                $checkName = '积分提现';
                break;
            default:
                $checkName = '';
                break;
        }
        if (!empty($checkName)) {
            $checkName = "【{$checkName}】";
        }
        $text = "你有一个新的{$checkName}审核,请及时处理";
        $message = $this->getMessage($text);
        //发送消息
        dingtalk()->sendMessage($people, $message);

    }
}